package com.frame.exception

import org.apache.shiro.authz.UnauthorizedException
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import javax.ws.rs.core.Response
import javax.ws.rs.ext.ExceptionMapper
import javax.ws.rs.ext.Provider

/**
 * Created by three on 14-8-4.
 */
@Provider
class UnauthorizedExceptionMapper implements ExceptionMapper<UnauthorizedException> {

    private Logger log = LoggerFactory.getLogger(UnauthorizedExceptionMapper.class);

    @Override
    Response toResponse(UnauthorizedException exception) {
        return Response.status(Response.Status.FORBIDDEN).entity("没有权限访问此资源，联系管理员分配权限").
                type("text/plain").build();
    }
}
